package cn.pw.test.com.news.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.flyco.tablayout.SegmentTabLayout;

import java.util.ArrayList;
import java.util.List;

import cn.pw.test.com.news.R;
import cn.pw.test.com.news.fragment.SchoolNewsFragment;
import cn.pw.test.com.news.manager.NewsPathManger;
import tech.com.commoncore.base.BaseTitleActivity;
import tech.com.commoncore.manager.TabLayoutManager;

@Route(path = NewsPathManger.NEWS_SCHOOL_NEWS)
public class SchoolNewsActivity extends BaseTitleActivity {

    private SegmentTabLayout segmentTab;
    private ViewPager viewPager;
    private String[] title;

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText(R.string.news_string_school_news_title);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_school_news;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        segmentTab = findViewById(R.id.segment_tab_layout);
        viewPager = findViewById(R.id.view_pager);

        title = new String[]{getString(R.string.news_string_school_basic_title),
                getString(R.string.news_string_school_technology_title),
                getString(R.string.news_string_school_experience_title)};

        List<Fragment> fragments = new ArrayList<>();
        fragments.add(SchoolNewsFragment.newInstance(1));
        fragments.add(SchoolNewsFragment.newInstance(2));
        fragments.add(SchoolNewsFragment.newInstance(3));

        TabLayoutManager.getInstance().setSegmentTabData(this, segmentTab, viewPager, title, fragments);
    }
}
